package com.liuqi.knet.rpc.cluster.loadbalance;

import com.liuqi.knet.rpc.cluster.ClusterConfig;
import com.liuqi.knet.rpc.cluster.LoadBalanceNode;
import java.util.List;

/**
 * 第一次随机从集群节点中获取一个, 再基于次索引进行轮询
 *
 * @author liuqi
 * @date 2024/6/20 10:44
 **/
public class RandomPointRoundLoadBalance extends RoundLoadBalance {

    public RandomPointRoundLoadBalance(ClusterConfig clusterConfig) {
        super(clusterConfig);
        List<LoadBalanceNode.Node> nodes = getLoadBalanceNode().getNodes();
        setPoint((int) (Math.random() * nodes.size()));
    }

}
